from django.contrib import admin
from .models import ZabbixServer, MonitoringHost, MonitoringAlert


@admin.register(ZabbixServer)
class ZabbixServerAdmin(admin.ModelAdmin):
    list_display = ['name', 'url', 'username', 'is_active', 'is_default', 'created_at']
    list_filter = ['is_active', 'is_default', 'created_at']
    search_fields = ['name', 'url', 'username']
    readonly_fields = ['created_at', 'updated_at']


# GrafanaServer管理已移除，使用Zabbix原生仪表板


@admin.register(MonitoringHost)
class MonitoringHostAdmin(admin.ModelAdmin):
    list_display = ['host', 'zabbix_server', 'zabbix_host_id', 'monitoring_status', 'last_check_time']
    list_filter = ['monitoring_status', 'zabbix_server', 'last_check_time']
    search_fields = ['host__hostname', 'host__private_ip', 'zabbix_host_id']


@admin.register(MonitoringAlert)
class MonitoringAlertAdmin(admin.ModelAdmin):
    list_display = ['title', 'severity', 'status', 'host', 'created_at']
    list_filter = ['severity', 'status', 'created_at']
    search_fields = ['title', 'description', 'host__hostname']
    readonly_fields = ['created_at', 'updated_at']
